function searchBills() {
    const remark = $('#remark').val();
    if (!remark) {
        alert('请输入备注名');
        return;
    }
    window.location.href = `/bill/list/`+remark;
}

$(document).ready(function() {
    // 处理 URL 中的参数
    const urlParams = new URLSearchParams(window.location.search);
    const remark = urlParams.get('remark');
    if (remark) {
        searchBills(remark);
    }
});

function updateBillList(data) {
    const $billListBody = $('#billListBody');
    $billListBody.empty();

    if (data.length > 0) {
        data.forEach(bill => {
            const row = `
                <tr>
                    <td>${bill[0]}</td>
                    <td>${bill[1]}</td>
                    <td>${bill[2]}</td>
                    <td>${bill[3]}</td>
                    <td>${bill[4]}</td>
                </tr>
            `;
            $billListBody.append(row);
        });
    } else {
        const row = `
            <tr>
                <td colspan="5">没有账单记录。</td>
            </tr>
        `;
        $billListBody.append(row);
    }
}